package com.dai.zhenfujin.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.dai.zhenfujin.BaseAdapter.BaseRecycleAdapter;
import com.dai.zhenfujin.BaseAdapter.BaseViewHolder;
import com.dai.zhenfujin.R;
import com.dai.zhenfujin.bean.TypeListBean;

import java.util.List;
public class IssueTypeAdpter extends BaseRecycleAdapter<TypeListBean.TypelistBean> {
    private List<TypeListBean.TypelistBean> dataList;
    private Context mContext;
    private BaseViewHolder.onItemCommonClickListener commonClickListener;



    public IssueTypeAdpter(Context context, List<TypeListBean.TypelistBean> dataList, BaseViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, com.dai.zhenfujin.R.layout.itme_issue_list);
        this.dataList = dataList;
        this.commonClickListener = commonClickListener;
        mContext = context;
    }

    @Override
    public void bindData(BaseViewHolder holder, TypeListBean.TypelistBean data) {
        if (!data.getT_name().equals("粉丝福利")) {
            holder.setText(com.dai.zhenfujin.R.id.tv_city, data.getT_name())
                    .setCommonClickListener(commonClickListener);
            holder.getView(R.id.iv_type).setVisibility(View.VISIBLE);
            holder.getView(R.id.tv_city).setVisibility(View.VISIBLE);
            if (TextUtils.isEmpty(data.getT_url())) {
                holder.getView(R.id.iv_type).setVisibility(View.GONE);
            } else {
                holder.getView(R.id.iv_type).setVisibility(View.VISIBLE);
                Glide.with(mContext).load(data.getT_url()).into((ImageView) holder.getView(com.dai.zhenfujin.R.id.iv_type));
            }
        }else {
            holder.getView(R.id.iv_type).setVisibility(View.GONE);
            holder.getView(R.id.tv_city).setVisibility(View.GONE);
        }
         TextView tv_name =  holder.getView(R.id.tv_city);
         if (holder.getView(R.id.tv_city).isClickable()){
             tv_name.setTextColor(mContext.getResources().getColor(R.color.yellow));
         }
    }
}
